%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for queries/connections/pagination-when-inlined-backwards-nodes-only"
    Bucket0("Bucket 0 (root)<br /><br />1: <br />ᐳ: 10, 11, 59, 62, 63, 12, 14, 29<br />2: PgSelect[9]<br />3: PgSelectRows[15]"):::bucket
    Bucket1("Bucket 1 (listItem)<br />Deps: 12, 59, 29<br /><br />ROOT __Item{1}ᐸ15ᐳ[16]"):::bucket
    Bucket2("Bucket 2 (nullableBoundary)<br />Deps: 17, 12, 59, 29<br /><br />ROOT PgSelectSingle{1}ᐸforumsᐳ[17]<br />1: <br />ᐳ: 18, 20, 26<br />2: PgSelect[21]<br />3: Connection[25]"):::bucket
    Bucket3("Bucket 3 (nullableBoundary)<br />Deps: 25, 12, 20, 59, 26, 29, 21<br /><br />ROOT Connection{2}ᐸ21ᐳ[25]<br />1: ConnectionItems[30], PgSelect[34]<br />ᐳ: 33, 41, 42, 44, 43, 45, 46, 47<br />2: PgSelectRows[36]<br />ᐳ: 35, 37, 38"):::bucket
    Bucket5("Bucket 5 (listItem)<br />Deps: 12<br /><br />ROOT __Item{5}ᐸ30ᐳ[39]"):::bucket
    Bucket6("Bucket 6 (nullableBoundary)<br />Deps: 40, 12<br /><br />ROOT PgSelectSingle{5}ᐸmessagesᐳ[40]<br />1: <br />ᐳ: 48, 49<br />2: PgSelect[50]<br />3: PgSelectRows[55]<br />ᐳ: First[54], PgSelectSingle[56]"):::bucket
    Bucket7("Bucket 7 (nullableBoundary)<br />Deps: 56<br /><br />ROOT PgSelectSingle{6}ᐸusersᐳ[56]"):::bucket
    end
    Bucket0 --> Bucket1
    Bucket1 --> Bucket2
    Bucket2 --> Bucket3
    Bucket3 --> Bucket5
    Bucket5 --> Bucket6
    Bucket6 --> Bucket7

    %% plan dependencies
    PgSelect9[["PgSelect[9∈0] ➊<br />ᐸforumsᐳ<br />More deps:<br />- Object[12]<br />- Constantᐸ2ᐳ[59]"]]:::plan
    Lambda14{{"Lambda[14∈0] ➊<br />ᐸincludeArchivedConditionᐳ<br />More deps:<br />- Constantᐸ[ undefined, 'YES' ]ᐳ[62]"}}:::plan
    Lambda14 --> PgSelect9
    Object12{{"Object[12∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ<br />Dependents: 4"}}:::plan
    Access10{{"Access[10∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access11{{"Access[11∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access10 & Access11 --> Object12
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access10
    __Value2 --> Access11
    PgSelectRows15[["PgSelectRows[15∈0] ➊"]]:::plan
    PgSelect9 --> PgSelectRows15
    Lambda29{{"Lambda[29∈0] ➊<br />ᐸincludeArchivedConditionᐳ<br />Dependents: 2<br />More deps:<br />- Constantᐸ[HIDDEN]ᐳ[63]"}}:::plan
    __Item16[/"__Item[16∈1]<br />ᐸ15ᐳ"\]:::itemplan
    PgSelectRows15 ==> __Item16
    PgSelectSingle17{{"PgSelectSingle[17∈1]<br />ᐸforumsᐳ"}}:::plan
    __Item16 --> PgSelectSingle17
    PgSelect21[["PgSelect[21∈2]<br />ᐸmessages+1ᐳ<br />More deps:<br />- Object[12]<br />- Constantᐸ2ᐳ[59]<br />- Lambda[29]"]]:::plan
    PgClassExpression20{{"PgClassExpression[20∈2]<br />ᐸ__forums__.”id”ᐳ"}}:::plan
    PgClassExpression26{{"PgClassExpression[26∈2]<br />ᐸ__forums__...chived_at”ᐳ"}}:::plan
    PgClassExpression20 & PgClassExpression26 --> PgSelect21
    Connection25[["Connection[25∈2]<br />ᐸ21ᐳ<br />More deps:<br />- Constantᐸ2ᐳ[59]"]]:::plan
    PgSelect21 --> Connection25
    PgClassExpression18{{"PgClassExpression[18∈2]<br />ᐸ__forums__.”name”ᐳ"}}:::plan
    PgSelectSingle17 --> PgClassExpression18
    PgSelectSingle17 --> PgClassExpression20
    PgSelectSingle17 --> PgClassExpression26
    PgSelect34[["PgSelect[34∈3]<br />ᐸmessages(aggregate)ᐳ<br />More deps:<br />- Object[12]<br />- Constantᐸ2ᐳ[59]<br />- Lambda[29]"]]:::plan
    PgClassExpression20 & PgClassExpression26 --> PgSelect34
    PgCursor45{{"PgCursor[45∈3]"}}:::plan
    First43{{"First[43∈3]"}}:::plan
    Access44{{"Access[44∈3]<br />ᐸ21.cursorDetailsᐳ"}}:::plan
    First43 & Access44 --> PgCursor45
    PgCursor47{{"PgCursor[47∈3]"}}:::plan
    Last46{{"Last[46∈3]"}}:::plan
    Last46 & Access44 --> PgCursor47
    ConnectionItems30[["ConnectionItems[30∈3]"]]:::plan
    Connection25 --> ConnectionItems30
    PageInfo33{{"PageInfo[33∈3]"}}:::plan
    Connection25 --> PageInfo33
    First35{{"First[35∈3]"}}:::plan
    PgSelectRows36[["PgSelectRows[36∈3]"]]:::plan
    PgSelectRows36 --> First35
    PgSelect34 --> PgSelectRows36
    PgSelectSingle37{{"PgSelectSingle[37∈3]<br />ᐸmessagesᐳ"}}:::plan
    First35 --> PgSelectSingle37
    PgClassExpression38{{"PgClassExpression[38∈3]<br />ᐸcount(*)ᐳ"}}:::plan
    PgSelectSingle37 --> PgClassExpression38
    Access41{{"Access[41∈3]<br />ᐸ25.hasNextPageᐳ"}}:::plan
    PageInfo33 o--o Access41
    Access42{{"Access[42∈3]<br />ᐸ25.hasPreviousPageᐳ"}}:::plan
    Access41 o--o Access42
    ConnectionItems30 --> First43
    PgSelect21 --> Access44
    ConnectionItems30 --> Last46
    __Item39[/"__Item[39∈5]<br />ᐸ30ᐳ"\]:::itemplan
    ConnectionItems30 ==> __Item39
    PgSelectSingle40{{"PgSelectSingle[40∈5]<br />ᐸmessagesᐳ"}}:::plan
    __Item39 --> PgSelectSingle40
    PgSelect50[["PgSelect[50∈6]<br />ᐸusersᐳ<br />More deps:<br />- Object[12]"]]:::plan
    PgClassExpression49{{"PgClassExpression[49∈6]<br />ᐸ__messages...author_id”ᐳ"}}:::plan
    PgClassExpression49 --> PgSelect50
    PgClassExpression48{{"PgClassExpression[48∈6]<br />ᐸ__messages__.”body”ᐳ"}}:::plan
    PgSelectSingle40 --> PgClassExpression48
    PgSelectSingle40 --> PgClassExpression49
    First54{{"First[54∈6]"}}:::plan
    PgSelectRows55[["PgSelectRows[55∈6]"]]:::plan
    PgSelectRows55 --> First54
    PgSelect50 --> PgSelectRows55
    PgSelectSingle56{{"PgSelectSingle[56∈6]<br />ᐸusersᐳ"}}:::plan
    First54 --> PgSelectSingle56
    PgClassExpression57{{"PgClassExpression[57∈7]<br />ᐸ__users__.”username”ᐳ"}}:::plan
    PgSelectSingle56 --> PgClassExpression57
    PgClassExpression58{{"PgClassExpression[58∈7]<br />ᐸ__users__....vatar_url”ᐳ"}}:::plan
    PgClassExpression57 o--o PgClassExpression58

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value2,PgSelect9,Access10,Access11,Object12,Lambda14,PgSelectRows15,Lambda29 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1,__Item16,PgSelectSingle17 bucket1
    classDef bucket2 stroke:#7f007f
    class Bucket2,PgClassExpression18,PgClassExpression20,PgSelect21,Connection25,PgClassExpression26 bucket2
    classDef bucket3 stroke:#ffa500
    class Bucket3,ConnectionItems30,PageInfo33,PgSelect34,First35,PgSelectRows36,PgSelectSingle37,PgClassExpression38,Access41,Access42,First43,Access44,PgCursor45,Last46,PgCursor47 bucket3
    classDef bucket5 stroke:#7fff00
    class Bucket5,__Item39,PgSelectSingle40 bucket5
    classDef bucket6 stroke:#ff1493
    class Bucket6,PgClassExpression48,PgClassExpression49,PgSelect50,First54,PgSelectRows55,PgSelectSingle56 bucket6
    classDef bucket7 stroke:#808000
    class Bucket7,PgClassExpression57,PgClassExpression58 bucket7

